<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link rel="stylesheet" href="/static/lib/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/lib/layuiadmin/style/admin.css" media="all">
    <style type="text/css">

        body {
              height: 100%;
              overflow: hidden;
          }
        html {
            height: 99%;
        }

    </style>
</head>
<body>

<div id="divBody" style="height: 100%;">

    <!--<div id="noWf" style="display: none; margin: 50px 0px 0px 50px">-->
        <!--没有找到可以发起的申请-->
    <!--</div>-->
    <div class="layui-fluid" id="LAY-component-grid-mobile" style="height: 100%;">
        <div class="layui-row layui-col-space20" style="height: 100%; margin-top: 10px">
            <div class="layui-col-xs2" style="height: 100%;">
                <div class="layui-card" style="height: 100%;">
                    <div class="layui-card-header">流程列表</div>
                    <div class="layui-card-body" style="height: 92%; overflow: auto;">
                        <ul>
                            <li v-for="(itemWf,indexWf) in workflows">
                                <a :href="'./workInstance.html?editFlag=1&activityId=' + itemWf.activityId + '&wfId=' + itemWf.wfId" target="startForm" onclick="workflow_click($(this))">
                                    <i class="layui-icon" v-if="indexWf==0">&#xe614;</i>
                                    <i class="layui-icon" v-else>&#xe620;</i>
                                    {{itemWf.wfName}}
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="layui-col-xs10" style="height: 100%;" >
                <iframe id="startForm" name="startForm" style="border: 0px solid red; overflow: auto; width: 100% !important; height: 100% !important; background-color: #fff;"></iframe>
            </div>
        </div>
    </div>
</div>
<script src="/static/js/vue.min.js"></script>
<script src="/static/lib/layuiadmin/layui/layui.js"></script>
<script src="/static/lib/layuiadmin/layui/layui.all.js"></script>
<script language="JavaScript">
    var $ = layui.$

    var vueData = new Vue({
        el: "#divBody",
        data: {
            workflows: []
        },
        beforeCreate: function () {
            $.post("/wf/activity/authority/getAllByUser", {}, function (data) {
                if (data.OK != "OK") {
                    layer.alert(data.message);
                    return;
                }

                if (data.List.length < 1) {
                    // $("#noWf").css("display", "block")
                    layer.alert("没有找到可以发起的申请!", {icon: 3, shade: 0.3});
                    $("#tabWf").css("display", "none")
                    return
                }

                Vue.set(vueData, "workflows", data.List)

                $("#noWf").css("display", "none")
                $("#tabWf").css("display", "block")
                $("#startForm").attr("src", "./workInstance.html?editFlag=1&activityId=" + data.List[0].activityId + "&wfId=" + data.List[0].wfId);


            })
        },
        created: function () {
            // tabAutoFit()
        }
    })

    // $(window).resize(function () {
    //     // tabAutoFit()
    // })
    //
    function tabAutoFit() {
        var wftab = document.getElementById("wfTab");
        wftab.style.width = (window.innerWidth - 38) + 'px';
        wftab.style.height = (window.innerHeight - 90) + 'px';
    }
    
    function workflow_click(_this) {
        _this.parent().siblings().children("a").children("i").html("&#xe620;");
        _this.children("i").html("&#xe614;");
    }

</script>
</body>
</html>